#include "inflatestream.h"

InflateStream::InflateStream(QIODevice *parent) : QObject(parent), input(NULL), output(NULL)
{
#if 0
  strm.zalloc   = Z_NULL;
  strm.zfree    = Z_NULL;
  strm.opaque   = Z_NULL;
  strm.avail_in = 0;
  strm.next_in  = Z_NULL;

  inflateInit2(&strm, MAX_WBITS | 16);
#endif
  input  = new char[BUFFER_SIZE];
  output = new char[BUFFER_SIZE];
}

InflateStream::~InflateStream()
{
//  inflateEnd(&strm);
  delete input;
  delete output;
}

QByteArray InflateStream::readAll()
{
#if 0
  if (parent() == NULL)
    return QByteArray();

  strm.next_in   = (Bytef *) input;
  strm.avail_in  = qobject_cast<QIODevice *>(parent())->read(input, BUFFER_SIZE);
  strm.next_out  = (Bytef *) output;
  strm.avail_out = BUFFER_SIZE;

  inflate(&strm, Z_SYNC_FLUSH);

  if (strm.avail_out == 0)
    return QByteArray();

  return QByteArray(output, BUFFER_SIZE - strm.avail_out);
#endif
  return QByteArray();
}
